/*
Copyright (c) 2006 - 2008  Universitaet Osnabrueck, virtUOS
Authors: Markus Ketterl, Johannes Emden, Nils Schuhmacher, Andreas Rickling

This file is part of virtPresenter.

virtPresenter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

virtPresenter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with virtPresenter.  If not, see <http://www.gnu.org/licenses/>.
*/

package virtPresenter.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	import virtPresenter.event.*;
	import virtPresenter.model.*;
	import flash.net.LocalConnection;
	
	/**
	 * Command lets the presentation go to the previous animationStep.
	 * */
	public class GoToPreviousAnimationStep implements ICommand {
				
		public function GoToPreviousAnimationStep() {}
		
		/**
		 * Handles a GoToPreviousAnimationStepEvent and lets the presentation go to the previous animationstep
		 * on the slide. Sets the VideoPlayer to the timestep of the next slide and therefor invokes
		 * a VideoPlayerTimeChangeEvent through the AdvancedScrubber.
		 * */	
		 	
		public function execute( event : CairngormEvent ): void {			    
			   
			    var model : virtPresenterLocator = virtPresenterLocator.getInstance();
			    var previousTimeStep:TimeStep=model.xmlParser.getPreviousStep(model.currentvideotime*1000);
			    var previous_time:int=previousTimeStep.getTime();
			    var prevTime_sec:Number=previous_time/1000+0.5;			   
			    trace("GoToPreviousAnimationStep. Back to step/time (sec):" +previousTimeStep.getStep()+"/"+ prevTime_sec);
			    //trace("GoToPreviousAnimationStep. Current video time:" + model.currentvideotime);
			    model.netStream.seek(prevTime_sec);
			   			    			
		}
	
		
	}
}